import requests
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'
}
kw = input('请输入要搜索关键字：')
url = 'https://www.sogou.com/web'
param = {
    'query':kw
}
response = requests.get(url=url,params=param,headers=headers)
page = response.text
filename = kw + '.html'
with open(filename,'w',encoding='utf-8') as f:
    f.write(page)
